package domainmodel;

import java.awt.Color;
import java.util.HashMap;
import java.util.Map;

public class ColorConverter {
	public Map<String, Color> colors = new HashMap<String, Color>();

	/**
	 * Creates a ColorConvertor to convert Strings to Colors.
	 */
	public ColorConverter(){
		
		colors.put("red", Color.RED);
		colors.put("green", Color.GREEN);
		colors.put("blue", Color.BLUE);
		colors.put("yellow", Color.YELLOW);
		colors.put("black", Color.BLACK);
		colors.put("white", Color.WHITE);
		colors.put("orange", Color.ORANGE);
	}
	
	/**
	 * Converts a given String to a Color object.
	 * 
	 * @param color
	 *            The string to convert.
	 *            If no string is given, an IllegalArgumentException is thrown.
	 * @throws IllegalArgumentException
	 *             If color-string is given.
	 */
	public Color getColor(String color) {
		if(color == null){
			throw new IllegalArgumentException("Color should not be null.");
		}
		return colors.get(color.toLowerCase());
	}
}
